import Vue from 'vue'
import Vuex from 'vuex'
import actions from './actions'
import getters from './getters'
import mutations from './mutations'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const debug = process.env.NODE_ENV !== 'production'

const state = {
  isLogin: false,
  token: '',
  openId: '',
  userInfo: {},
  masterCatalogs: [],
  masterLevels: [],
  paintingCatalogs: [],
  questionCatalogs: [],
  newsCatalogs: [],
  answers: [],
  localAnswers: []
}

const store = new Vuex.Store({
  state,
  actions,
  getters,
  mutations,
  strict: debug,
  plugins: [
    createPersistedState({
      paths: ['isLogin', 'token', 'openId', 'userInfo']
    })
  ]
})

export default store
